<?php

namespace App\Admin\Actions\SmsSendError;

use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use App\Models\SmsSendError;
use Illuminate\Http\Request;
use App\Jobs\SyncSendSms;
use Illuminate\Support\Facades\Log;

class ResentSms extends RowAction
{
    public $name = '重新发送';

    public function dialog()
    {
        $this->confirm('确定重新发送？');
    }

    public function handle(Model $model)
    {
        $logRow  = SmsSendError::where("id", $this->getKey())->first();
        if ($logRow) {
            // $content = '【欢生活】尊敬的用户，您获得了一张家政服务抵用券，点链接 '.config('app.url').' 使用。回复T退订';

            // SmsSendError::create([
            //     'mobile' => $mobiles,
            //     'action' => $this->action,
            //     'resp_content' => 'shmtn.b2m.cn 接口错误',
            //     'other_infos' => json_encode($this->otherInfos)
            // ]);

            return $this->response()->success('重新发送.');
        } else {
            return $this->response()->error('获取不到手机号.');
        }
    }
}